import { ApiCall } from "tsrpc";
import { ReqOpen_ExpBook, ResOpen_ExpBook } from "../../../../shared/master/bag/function/PtlOpen_ExpBook";
import { player } from "../../../../model/fight/body/player";
import { template } from "../../../../shared/master/MsgAction";

export default async function (call: ApiCall<ReqOpen_ExpBook, ResOpen_ExpBook>) {
    call.succ({})
    if (call.req.num <= 0) {
        call.req.num = 1;
    }
    let user = call.req._player as player;
    let res = user.check_wallet(0, 0, [{ id: 'prop-17', v: call.req.num }], false, `使用经验书x${call.req.num}`, true);
    if (!res.state) {
        return;
    }
    user.addExp(100 * call.req.num);
    user.sendMsg(template.default,`已获得:战斗经验+${100 * call.req.num}`)
}